namespace ValidationFramework
{
	/// <summary>
	/// The results of any <see cref="ValidationFramework.Rule.Validate"/> operation.
	/// </summary>
	public class ValidationResult
	{
		// --- Consructors


		/// <remarks>
		/// On construction this represents the results of a valid test.
		/// </remarks>
		/// <param name="rule">The <see cref="Rule"/> that this <see cref="ValidationResult"/> has been generated from.</param>
		/// <param name="testedValue">The value that was tested.</param>
        public ValidationResult(Rule rule, object testedValue)
		{
			//Dont guard these. the performance hit is not worth the minor help it gives developers. 

			Rule = rule;
			TestedValue = testedValue;
			ErrorMessage = "The value is passed the test.";
			PassedTest = true;
		}


		// --- Properties


		/// <summary>
		/// Gets a value indicating whether a test was passed
		/// </summary>
		public bool PassedTest { get; private set; }

		/// <summary>
		/// Gets the error message for a failed test.
		/// </summary>
		public string ErrorMessage
		{
			get;
			private set;
		}

		/// <summary>
		/// Gets the <see cref="Rule"/> that this <see cref="ValidationResult"/> has been generated from.
		/// </summary>
		/// <seealso cref="ValidationFramework.Rule.Validate"/>
        public Rule Rule
		{
			get;
			private set;
		}

		/// <summary>
		/// Gets the value of the object that was tested
		/// </summary>
		public object TestedValue { get; private set; }


		// --- Methods

		public ValidationResult MarkAsFailed(string message)
		{
			PassedTest = false;
			ErrorMessage = message;
			return this;
		}


	}
}
